package com.qfedu.labsystem.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @ClassName Consumer
 * @Author ykx
 * @Date 2024/4/12 14:15
 * @Version 1.0
 */
@Component
public class Consumer {
    @RabbitListener(queues = "boot-queue")
    public void getMessage(String msg, Channel channel, Message message) throws IOException {
        System.out.println("接收到消息：" + msg);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }

}
